from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
	user = models.ForeignKey(User)
	location = models.CharField(max_length = 255)
	friends = models.ManyToManyField('self')
	friend_requests = models.ManyToManyField('self', through = 'FriendRequest', symmetrical = False, related_name = 'friend_request')
	feed_posts = models.ManyToManyField('self', through = 'FeedPost', symmetrical = False, related_name = 'feed_post')

class FriendRequest(models.Model):
        from_user = models.ForeignKey(UserProfile, related_name = 'fr_sender')
        to_user = models.ForeignKey(UserProfile, related_name = 'fr_recipient')
        message = models.CharField(max_length = 255, null = True)

class FeedPost(models.Model):
	from_user = models.ForeignKey(UserProfile, related_name = 'fp_sender')
	to_user = models.ForeignKey(UserProfile, related_name = 'fp_recipient')
	message = models.TextField()
	date_added = models.DateField(auto_now_add = True)

